package cn.bdqn.utils;

import java.net.MalformedURLException;

public class smssendDome {
	
	public static void main(String[] args) throws MalformedURLException {
		String vhq8V9 = sendSMS("http://www.cqhuatang.com", "031775", "VHQ8V9", "17265861354", null, "1603445177114RB0", "尊敬的用户：您的验证码为2356，十分钟内有效，请妥善保管【两江集群创业创新中心】");
		System.out.println(vhq8V9);
	}

	/**
	 * 发送短信接口
	 * wangjie
	 * 2017-8-8 17:38:34
	 * @param ip http://ip:port/smssend
	 * @param port
	 * @param appkey  app登录名
	 * @param appsecret   appsecret	app登录密码
	 * @param phone   接收手机号码
	 * @param extnum  扩展码
	 * @param templateid   已报备的模板id（模板中用“{?}”表示参数）
	 * @param templateparams   短信参数（字符串数组，元素个数与对应模板中的参数个数相同）
	 * @return
	 * @throws MalformedURLException
	 */
	public static String sendSMS(String url,String appkey,String appsecret,String phone,String extnum,String templateid,String templateparams) throws MalformedURLException{
		String str = "{\"appkey\":\""+appkey+"\",\"appsecret\":\""+appsecret+"\",\"phone\":\""+phone+"\",\"extnum\":\""+extnum+"\",\"templateid\":\""+templateid+"\",\"content\":\""+templateparams+"\"}";
		//String str = "appkey="+appkey+"&appsecret="+appsecret+"&phone="+phone+"&extnum="+extnum+"&templateid="+templateid+"&templateparams="+templateparams;
		url = new String(url+"/SMSServer/sendFullTextSms");
		String sb = null;
		sb = HttpRequest.sendPost(url, str);
		return sb;
	}
	/**
	 * 接受回复接口
	 * wangjie
	 * 2017-8-8 17:39:52
	 * @param ip
	 * @param port
	 * @param appkey
	 * @param appsecret
	 * @return
	 * @throws MalformedURLException
	 */
	public static String smsreceive(String ip,String port,String appkey,String appsecret) throws MalformedURLException{
		String url= null;
		String str = "{\"appkey\":\""+appkey+"\",\"appsecret\":\""+appsecret+"\"}";
		url = new String(ip+":"+port+"/smsreceive");
		String sb = null;
		sb = HttpRequest.sendPost(url, str);
		return sb;
	}
	/**
	 * 接受状态接口
	 * wangjie
	 * 2017-8-8 17:41:27
	 * @param ip
	 * @param port
	 * @param appkey
	 * @param appsecret
	 * @return
	 * @throws MalformedURLException
	 */
	public static String smsstatus(String ip,String port,String appkey,String appsecret) throws MalformedURLException{
		String url= null;
		String str = "{\"appkey\":\""+appkey+"\",\"appsecret\":\""+appsecret+"\"}";
		url = new String(ip+":"+port+"/smsstatus");
		String sb = null;
		sb = HttpRequest.sendPost(url, str);
		return sb;
	}
	/**
	 * 查询余额接口
	 * wangjie
	 * 2017-8-8 17:42:27
	 * @param ip
	 * @param port
	 * @param appkey
	 * @param appsecret
	 * @return
	 * @throws MalformedURLException
	 */
	public static String smsbalance(String ip,String port,String appkey,String appsecret) throws MalformedURLException{
		String url= null;
		String str = "{\"appkey\":\""+appkey+"\",\"appsecret\":\""+appsecret+"\"}";
		url = new String(ip+":"+port+"/smsbalance");
		String sb = null;
		sb = HttpRequest.sendPost(url, str);
		return sb;
	}
	
	
	

}
